#include"processBar.h"

typedef void (*callback_t)(int); // 函数指针类型

void downLoad(callback_t cb)
{
	int total=1000;
	int curr=0;
	while(curr<=total)
	{
		usleep(50000);
		int rate=curr*100/total;

		cb(rate);

		curr+=10;
	}
	printf("\n");
}

int main()
{
    	printf("donwnload 1: \n");
    	downLoad(processbar);
    	initbar();
    	printf("donwnload 2: \n");
    	downLoad(processbar);
    	initbar();
    	printf("donwnload 3: \n");
    	downLoad(processbar);
    	initbar();
    	printf("donwnload 4: \n");
    	downLoad(processbar);
    	initbar();

	//processbar();	

	// 简单数字倒计时的实现
	/*int cnt=10;
	while(cnt>=0)
	{
		printf("%-2d\r",cnt);
		fflush(stdout);
		cnt--;
		sleep(1);
		//usleep(100000);	
	}*/
	return 0;
}
